<template>
	<view>
		<uni-section title="我的工作" type="line"></uni-section>
		<view class="grid-body">
			<uni-grid :column="4" :showBorder="false" @change="changeGrid">
				<uni-grid-item v-for="(item, i) in grid" :key="i" :index="i">
					<view class="grid-item-box">
						<uni-icons :type="item.icon" size="30"></uni-icons>
						<text class="text">{{item.label}}</text>
					</view>
				</uni-grid-item>
			</uni-grid>
		</view>
	</view>
</template>

<script>
	import { checkPermi } from "@/utils/permission.js"
	import config from '@/config'
	const baseUrl = config.baseUrl
	export default {
		data() {
			return {
				current: 0,
				swiperDotIndex: 0,
				showScan: true,
				grid: [{
						label: '投诉查询',
						icon: 'cart',
						url: '/pages/inOut/purchase'
					},
					{
						label: '访客确认',
						icon: 'redo',
						url: '/pages/inOut/revert'
					},
					{
						label: '值班记录',
						icon: 'undo',
						url: '/pages/inOut/out'
					},
					{
						label: '巡更记录',
						icon: 'shop-filled',
						url: '/pages/stock/my'
					},
					{
						label: '作业管理',
						icon: 'gear-filled',
						url: '/pages/maintain/my'
					},
					{
						label: '报修确认',
						icon: 'gear-filled',
						url: '/pages/maintain/my'
					}
				]
			}
		},
		onLoad() {
			// #ifdef WEB || H5
			this.showScan = false;
			// #endif			
		},
		methods: {
			changeGrid(e) {
				if(e.detail.index >= this.grid.length){
					this.doScan();
				}else{
					let url = this.grid[e.detail.index].url
					this.$tab.navigateTo(url);
				}				
			}			
		}
	}
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff;
		min-height: 100%;
		height: auto;
	}

	view {
		font-size: 14px;
		line-height: inherit;
	}

	/* #endif */

	.text {
		text-align: center;
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.grid-item-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 15px 0;
	}

	.uni-margin-wrap {
		width: 690rpx;
		width: 100%;
		;
	}

	.swiper {
		height: 300rpx;
	}

	.swiper-box {
		height: 150px;
	}

	.swiper-item {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
		color: #fff;
		height: 300rpx;
		line-height: 300rpx;
	}

	@media screen and (min-width: 500px) {
		.uni-swiper-dot-box {
			width: 400px;
			/* #ifndef APP-NVUE */
			margin: 0 auto;
			/* #endif */
			margin-top: 8px;
		}

		.image {
			width: 100%;
		}
	}
</style>